<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="d" uri="http://dgg.net/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>证书待新增列表</title>
    <%@ include file="../../../header.jsp" %>
</head>
<body class="body-main">
<div class="titleSearch">
    <div class="layui-inline">
        <label>客户电话：</label>
        <div class="layui-input-inline">
            <input type="text" class="input-style" name="contactPhone">
        </div>
    </div>

    <d:hasUrlAuth authCode="ZZSC_ZS_SYB">
        <div class="layui-inline">
            <label>所属事业部：</label>
            <div class="layui-input-inline">
                <select name="signOrgId" id="signOrgId" class="input-style" autocomplete="off">
                    <option value="">全部</option>
                </select>
            </div>
        </div>
    </d:hasUrlAuth>

    <div class="layui-inline">
        <label>付款方式：</label>
        <div class="layui-input-inline">
            <select class="select-style" name="costState">
                <option value="">全部</option>
                <c:forEach var="p" items="${costStates}">
                    <option value="${p.code}">${p.name}</option>
                </c:forEach>
            </select>
        </div>
    </div>
    <div class="layui-inline">
        <label>付款类型：</label>
        <div class="layui-input-inline">
            <select class="select-style" name="payMethod">
                <option value="">全部</option>
                <c:forEach var="p" items="${payMethods}">
                    <option value="${p.code}">${p.name}</option>
                </c:forEach>
            </select>
        </div>
    </div>
    <div class="layui-inline">
        <label>关键字：</label>
        <div class="layui-input-inline">
            <input type="text" class="input-style win250" name="keyWords" placeholder="客户姓名/收证商务/销售子订单编号"/>
        </div>
    </div>
    <div class="layui-inline">
        <button class="layui-btn layui-btn-mini layui-btn-normal" onclick="search('#myTable','reload')">搜索</button>
        <button class="layui-btn layui-btn-mini layui-btn-primary" onclick="cleanSearch()">清空</button>
    </div>
</div>
<div class="table-conter" >
    <button class="layui-btn layui-btn-mini layui-btn-normal" onclick="checkCertificate()" name="add">新增入库</button>
    <div class="fr other-span">
        <div class="fr other-span">
            <span class="bgRed">入库超期</span>
        </div>
    </div>
</div>
<table id="myTable" class="cell-border crm-table">
</table>
<%@ include file="../../../footer.jsp" %>

<script src="${baseStaticUrl}/static/plugs/date-picker/WdatePicker.js"></script>
<script src="${rootUrl}/static/js/zzsc/common/verificationTool.js?v=${version}"></script>
<script src="${rootUrl}/static/js/zzsc/common/functionalTool.js?v=${orderBusinessNoversion}"></script>
<script src="${rootUrl}/static/js/zzsc/common/dealDataTool.js?v=${version}"></script>
<script src="${rootUrl}/static/js/zzsc/credential/credentailCommon/credentailCommon.js?v=${version}"></script>
<script src="${rootUrl}/static/js/zzsc/credential/waitCredential/addCredential.js?v=${version}"></script>
<script src="${rootUrl}/static/js/zzsc/credential/generalCertificate/editReturnGeneralCertificate.js?v=${version}"></script>
<script>
    $(function () {
        $('#myTable').dataTableExtend({
            "ajax": {
                "url": "${rootUrl}/zs/general_credential/wait_add_data.do",
                "type": "post"
            }, "fnServerParams": function (aoData) {
                var checkResult = checkHasSybAuth($('#signOrgId option'));
                if (!checkResult) {
                    aoData = $.extend(aoData, {"isAll": "0"});
                }
                aoData = $.extend(aoData, $('.titleSearch').serialize2object());
                return aoData;
            },
            "pageLength": 20,//每页显示的条数默认是10条，有特殊业务需要显示不同条数的列表才应该加入该参数
            "scrollX": true,//是否开启横项滚动
            "fixedColumns": {//锁定列，只有开启scrollX时才生效
                "leftColumns": 4,//左侧锁定2列
                "rightColumns": 1//右侧锁定1列
            },
            "aoColumns": [
                {
                    "title": '<input type="checkbox" class="checkall"/>',
                    "sClass": "check-th",
                    "orderable": false,
                    "data": "productId",
                    "render": function (data, type, full, meta) {
                        return '<input type="checkbox"  class="checkchild"  value="' + data + '" />';
                    }
                },
                {
                    "title": "序号",
                    "orderable": false,
                    "render": function (data, type, full, meta) {
                        return meta.row + 1;
                    }
                },
                {
                    "title": "所属事业部",
                    "data": "productOrgName",
                    "orderable": false
                },
                {
                    "title": "订单编号",
                    "data": "orderBusinessNo",
                    "orderable": false
                },
                {
                    "title": "客户",
                    "data": "customerPhone",
                    "orderable": false,
                    "render": function (data, type, row, meta) {
                        return row.customerName + "<br/>" + (!checkIsEmpty(row.customerPhone) ? hidePhone(row.customerPhone) : "");
                    }
                },
                {
                    "title": "产品",
                    "data": "productName",
                    "orderable": false,
                },
                {
                    "title": "合同金额",
                    "data": "money",
                    "orderable": false,
                    "render": function (data, type, row, meta) {
                        var money = null == data ? 0 : fmtMoney(data);
                        return money;
                    }
                },
                {
                    "title": "付款方式",
                    "data": "costState",
                    "orderable": false,
                    "render":
                        function (data, type, row, meta) {
                            var data = '已支付' == data ? '<a href="javascript:;"   class="label label-green" >' + data + "</a>" : data;
                            return data;
                        }
                },
                {
                    "title":
                        "付款类型",
                    "data":
                        "payMethod",
                    "orderable":
                        false
                }
                ,
                {
                    "title":
                        "付款金额",
                    "orderable":
                        false,
                    "render":

                        function (data, type, row, meta) {
                            var theDeposit = null == row.theDeposit ? 0 : row.theDeposit;
                            var balancePayment = null == row.balancePayment ? 0 : row.balancePayment;
                            var payCount = checkIsEmpty(theDeposit + balancePayment) ? 0 : fmtMoney(theDeposit + balancePayment);
                            return payCount;

                        }
                }
                ,
                {
                    "title":
                        "收证商务",
                    "data":
                        "signUserName",
                    "orderable":
                        false
                }
                ,
                {
                    "title":
                        "收证商务部门",
                    "data":
                        "signUserOrgName",
                    "orderable":
                        false
                }
                ,
                {
                    "title":
                        "下单时间",
                    "data":
                        "orderTime",
                    "orderable":
                        true,
                    "render":

                        function (data, type, row, meta) {
                            return data;
                        }
                }
                ,
                {
                    "title": "操作",
                    "orderable":false,
                    "data":
                        {}
                    ,
                    "render":
                        function (data, type, row, meta) {
                            var operation ='<d:hasUrlAuth authCode="ZZSC_DEL_ORDERBUSINESS"><a class="iboss-link"  href="javascript:void(0)" onclick="addCertificateCheck1(\'' + row.pid + '\')">新增入库</a></d:hasUrlAuth>';
                            operation += '<d:hasUrlAuth authCode="ZZSC_DEL_ORDERBUSINESS"><a class="iboss-link"  href="javascript:void(0)" onclick="delOrder(\'' + row.orderBusinessId + '\',\'' + row.orderBusinessNo + '\')">删除</a></d:hasUrlAuth>';
                            return operation.length > 0 ? operation:" - ";
                        }
                }
            ], "columnDefs": [{
            targets: [2], //第1，2，3列
                createdCell: function (td, cellData, rowData, row, col) {
                var state = rowData.state;

                if (1 == state) { // ??超期颜色
                    $(td).parent().addClass("bgRed");
                    return;
                }
            }
        }, {
            targets: ["_all"], "defaultContent": ""
        }]
        });

        // 加载事业部
        syb('[name="signOrgId"]');
    });

</script>
</body>
</html>